|
|
|
|
|
|
|
Figure 14.3
Close-up of a "bent rectangle" on a surface. |
|
|
|
|
|
|
|
|
Using an array of Point3D structures duplicates some of the surface's data. Because you know the X and Z coordinates of each point by its location in the array, you really do not need to store those coordinates in the Point3D structure. In other words, for the point corresponding to array entry Points(A, B), you know the point's untransformed X and Z coordinates are A and B. |
|
|
|
 |
|
|
|
|
Points(A, B).coord(1) = A
Points(A, B).coord(3) = B |
|
|
|
|
|
|
|
|
If you were to omit this data from the Point3D structure, however, you would need to rewrite the routines that apply a transformation matrix to the points. For a program with lots of surface data, this additional effort might be worth the space saved. In most cases, however, it is better to reuse the existing subroutines rather than creating a whole new set of routines to debug and maintain. |
|
|
|
|
|
|
|
|
The Grid3d class contains methods that make transforming and drawing the grid easy. The Apply method applies a transformation matrix to the surface. ApplyFull applies a matrix, such as a parallel projection matrix, that may not contain 0, 0, 0, 1 in its final column. The Draw method displays the transformed grid coordinates on a PictureBox. |
|
|
|
|
|
|
|
|
Example program Surface1 uses the Grid3d class to display several different kinds of surfaces. Use the option buttons to select the surface you want to display. Use the arrow keys to display the surface from different angles. |
|
|
|
|
|
|
|
|
In some cases, you can increase the number points you plot between the key locations in a grid. For instance, suppose you have a grid with X and Z values spaced one unit apart. In a normal grid, you would draw a line segment between the point (x1, y1, z1) and (x1 + 1, y2, z1). If you can calculate the extra data value, you can insert a new point at position (x1 + 0.5, y3, z1). This extra point breaks the original line segment into two segments that follow the surface more closely. You still draw the same number of curves parallel to the X and Z axes, but the curves contain more data points, so they represent the surface more accurately. |
|
|
|
|
|
|
|
|
Figure 14.4 shows a diagram of the X and Z coordinates used to draw a surface. You can think of these images as surfaces shown from directly above. The black dots indicate data points that are drawn to display the surface. The picture on the left connects each grid location as before. The picture on the right has one extra data point inserted between |
|
|
|
|
|